import table from '@/components/dt/table/render.js'
import Opt from '@/components/dt/info/Opt.js'
let _this = null
class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      {
        field: 'nodeOrder',
        title: '流程节点',
        minWidth: 80
      },

      {
        field: 'reviewerType',
        title: '审核人类型',
        minWidth: 120,
        slots: {
          default: (params, h) => {
            return [
              h(
                'div',
                params.row.reviewerType == 1
                  ? '角色'
                  : params.row.reviewerType == 2
                  ? '人员'
                  : params.row.reviewerType == 3
                  ? '发起人'
                  : '-'
              )
            ]
          }
        }
      },
      {
        field: 'reviewerMsg',
        title: '审核人',
        minWidth: 150
      },
      {
        field: 'leaderMsg',
        title: '任务责任人',
        minWidth: 150
      },
      {
        field: 'deductPoints',
        title: '驳回扣分节点',
        minWidth: 150,
        visible:_this.currentRow.taskDeductType==5
      },
      {
        title: '操作',
        fixed: 'right',
        width: 200,
        align: 'center',
        slots: {
          default: (params, h) => {
            let btns = []

            if(_this.currentRow.taskDeductType == 5){
              btns.push({
                title: params.$rowIndex != params.data.length - 1? '责任人节点': '',
                event:'editNode',
                data: params.row
              })
            }else{
              btns.push({
                title:
                  (_this.currentRow.taskDeductType == 3) && params.$rowIndex == params.data.length - 1
                    ? ''
                    : '编辑责任人节点',
                event:'editNode',
                data: params.row
              })
            }

            btns.push({
              title:_this.currentRow.taskDeductType == 5 && params.$rowIndex != 0? '扣分节点': '',
              event:'deductNode',
              data: params.row
            })
            return table.cell.btns(_this, h, btns)
          }
        }
      }
    ]
  }
}

export default Column
